package de.tum.in.eist.poll.client.views.widgets;

import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextArea;

import de.tum.in.eist.poll.shared.beans.Answer;
import de.tum.in.eist.poll.shared.beans.TextAnswer;
import de.tum.in.eist.poll.shared.beans.Lecture;
import de.tum.in.eist.poll.shared.beans.TextQuestion;
import de.tum.in.eist.poll.shared.beans.Student;

/**
 * @author Sebastian Hofstetter
 *
 */
public class QuestionTextWidget extends QuestionWidget{
	private TextQuestion question;
	
	private TextArea textArea;
	private Label   label;
	
	public QuestionTextWidget(TextQuestion question) {
		this.question = question;
		
		textArea = new TextArea();
		label   = new Label(this.question.getDescription());
		label.addStyleName("question");
		
		textArea.setTitle(this.question.getDescription());
		
		add(label);
		add(textArea);
	}
	
	public String getText() {
		return textArea.getText();
	}
	


	/* (non-Javadoc)
	 * @see de.tum.in.eist.poll.client.views.widgets.QuestionWidget#getFeedback()
	 */
	@Override
	public Answer getAnswer(Student student, Lecture lecture) {
		return new TextAnswer(student, lecture, textArea.getText());
	}
}
